<template>
  <div class="key-value-container" :class="'vertical-' + verticalAlign" @click.stop="$emit('self-click')">
    <div :class="'text-' + labelAlign" :style="{ width: labelWidth + 'px' }" class="key-value__title">
      <slot name="label">{{ label }}</slot>
    </div>
    <div :class="['text-' + textAlign, valueClass]" class="key-value__value" :title="value === '--' ? '' : value">
      <slot>{{ value }}</slot>
    </div>
  </div>
</template>

<script lang="ts" setup>
const emit = defineEmits(["self-click"]);
const props = withDefaults(
  defineProps<{
    label?: string;
    value?: string;
    textAlign?: string;
    labelAlign?: string;
    verticalAlign?: string;
    labelWidth?: number;
    valueClass?: string;
  }>(),
  {
    label: "--",
    value: "--",
    textAlign: "left",
    labelAlign: "left",
    verticalAlign: "middle",
  }
);
</script>

<style lang="less" scoped>
.key-value-container {
  background-color: transparent;
  white-space: nowrap;
  font-size: 14px;
  line-height: normal;
  display: flex;
  align-items: center;
  color: @color-secondary;
  margin-bottom: 10px;
  &.vertical-top {
    align-items: flex-start;
  }
  &.vertical-bottom {
    align-items: flex-end;
  }
  .key-value__title {
    flex: none;
    color: @color-secondary;
    text-align: left;
    width: 120px;
    &.text-center {
      text-align: center;
    }
    &.text-right {
      text-align: right;
    }
  }
  .key-value__value {
    white-space: normal;
    text-align: left;
    color: @color-main;
    &.text-center {
      text-align: center;
    }
    &.text-right {
      text-align: right;
    }
  }
}
</style>
